home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / bbs / cddk9606.zip / TUTOR.ARJ / TUTOR4.PAS < prev    next >
Pascal/Delphi Source File  |  1996-06-09  |  2KB  |  77 lines

  1.  
  2. PROGRAM Tutor4;
  3.  
  4. {$A+,B-,F+,I-,Q-,R-,S-,X+}
  5.  
  6. USES
  7.   Concerto, IO, Scripts, xStrings;
  8.  
  9. VAR
  10.   Entry  : pChar3;
  11.   Number : Byte;
  12.  
  13. BEGIN
  14.  
  15. { Our brief introduction to Concerto is finished.  Now we're going to
  16.   start working on an actual door game!  We trust, at this point, that
  17.   you will refer to the INT (interface) files if you are looking for
  18.   details not described in this and subsequent tutorials. }
  19.  
  20.  
  21. { As always, the first step is to initialize the door. }
  22.  
  23. RegisterConcerto;
  24. Script('Init');
  25.  
  26.  
  27. { Our door game is going to be simple -- after you, you probably want
  28.   to get started on your *own* game as soon as possible.  We are going
  29.   to make a number guessing name (no groans please!) ;-}
  30.  
  31.  
  32. { Select a random number from 1 to 100 }
  33.  
  34. Number:=Random(100)+1;
  35.  
  36. REPEAT
  37.  
  38.   { Display the prompt }
  39.  
  40.   Write(SO,'Enter your guess: ');
  41.  
  42.  
  43.   { Get a number from the user.  We are going to use the SI_pChar
  44.     procedure, which is a low-level pChar input routine.  It
  45.     accepts two parameters:
  46.  
  47.        1) a pChar to hold the result, and
  48.        2) the maximum length of the string.
  49.  
  50.     SI_pChar has a unique feature.  If the pChar is not empty, the user
  51.     will be allowed to edit the existing characters! This can be good at
  52.     times, but you'll have to erase the string if you need the user to
  53.     enter something from scratch.  See below. }
  54.  
  55.   Entry[0]:=#0;           { Erase the string }
  56.   SI_pChar(Entry,3);      { Get an entry (maximum 3 characters) }
  57.  
  58.  
  59.   { Check the answer... }
  60.  
  61.   IF p_Int(Entry)=Number THEN
  62.     BEGIN
  63.     WriteLn(SO,'|FFThe geezer actually won!|07~p');
  64.     ExitDoor(0);
  65.     END
  66.   ELSE
  67.     IF p_Int(Entry)>Number THEN
  68.       WriteLn(SO,'Too big, dummy.')
  69.     ELSE
  70.       WriteLn(SO,'Think bigger, peabrain.');
  71.  
  72. UNTIL False;
  73.  
  74. { This line will never be reached -- look closely at the UNTIL statement! }
  75.  
  76. END.
  77.